package com.seecen.service.impl;

import com.seecen.dao.EmpDao;
import com.seecen.entity.Dept;
import com.seecen.entity.Emp;
import com.seecen.service.DeptService;
import com.seecen.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;

@Service
public class EmpServiceImpl implements EmpService {

    @Autowired
    private EmpDao empDao;

    @Autowired
    private DeptService deptService;


    @Transactional(rollbackFor = Exception.class)
    public int save(Emp emp) throws IOException {
        int res = empDao.save(emp);
        deptService.save(emp.getDept());
        return res;
    }

}




